const host = "http://120.79.244.56:8088/";

$(function () {
    manageInfo()
});

//管理员登录注销
function manageInfo() {
    $.ajax({
        type: "post",
        url: host + "manage/manageInfo.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                $("#username").append("<span>" + jackson.data.username + "</span>")
            }
        }
    })
};

function loginOut() {
    $.ajax({
        type: "post",
        url: host + "manage/loginOut.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
                window.location.href = "login.html";
            }
        }
    })
};

//首页
function welcome() {
    $.ajax({
        type: "post",
        url: host + "manage/baseCount.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                $("#ordersCount").html(jackson.data.ordersCount);
                $("#commentsCount").html(jackson.data.commentsCount);
                $("#usersCount").html(jackson.data.usersCount);
                $("#communityCount").html(jackson.data.communityCount);
            }
        }
    })
};

//用户管理
function memberList() {
    $.ajax({
        type: "post",
        url: host + "manage/user/list.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#userList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td>" + jackson.data.list[i].username + "</td>" +
                        "<td>" + jackson.data.list[i].sex + "</td>" +
                        "<td>" + jackson.data.list[i].age + "</td>" +
                        "<td>" + jackson.data.list[i].phone + "</td>" +
                        "<td>" + jackson.data.list[i].address + "</td>" +
                        "<td>" + jackson.data.list[i].role + "</td>" +
                        "<td>" + getLocalTime(jackson.data.list[i].createTime) + "</td>" +
                        "<td class='td-manage'>\n" +
                        /*"<a title='编辑' onclick=\"x_admin_show('编辑','member-edit.html',600,400)\" href='javascript:;'>"
                        +
                        "<i class='layui-icon'>&#xe642;</i>" +
                        "</a>" +
                        "<a onclick=\"x_admin_show('修改密码','member-password.html',600,400)\" title='修改密码' href='javascript:;'>"
                        +
                        "<i class='layui-icon'>&#xe631;</i>" +
                        "</a>" +*/
                        "<a title='删除' onclick=\"memberDelete(this,'" + jackson.data.list[i].id + "')\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>")
                }
            }
        }
    })
};

function memberDelete(obj, id) {

    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/user/delete.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg(jackson.data, {icon: 1, time: 1000});
                }
            }
        })

    });
};

function memberRestoreList() {
    $.ajax({
        type: "post",
        url: host + "manage/user/restoreList.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#restoreList").append(
                        "<tr >\n" +
                        "<td>" + jackson.data.list[i].id + "</td>\n" +
                        "<td>" + jackson.data.list[i].username + "</td>\n" +
                        "<td>" + jackson.data.list[i].sex + "</td>\n" +
                        "<td>" + jackson.data.list[i].age + "</td>\n" +
                        "<td>" + jackson.data.list[i].phone + "</td>\n" +
                        "<td>" + jackson.data.list[i].address + "</td>\n" +
                        "<td>" + jackson.data.list[i].createTime + "</td>\n" +
                        "<td class=\"td-status\">\n" +
                        "<span class=\"layui-btn layui-btn-danger layui-btn-mini\">\n" +
                        "     已删除\n" +
                        "</span>\n" +
                        "<td class=\"td-manage\">\n" +
                        "<a title=\"恢复\" onclick=\"memberRestore(this, '" + jackson.data.list[i].id + "')\" href=\"javascript:;\">\n" +
                        "<i class=\"layui-icon\">&#xe770;</i>\n" +
                        "</a>\n" +
                        "</td>\n" +
                        "</tr>"
                    )
                }
            }
        }
    })
}

function memberRestore(obj, id) {

    layer.confirm('确认要恢复吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/user/restore.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg(jackson.data, {icon: 1, time: 1000});
                }
            }
        })

    });
};

//订单管理
function orderList() {
    $.ajax({
        type: "post",
        url: host + "manage/order/list.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#orderList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td>" + jackson.data.list[i].categoryId + "</td>" +
                        "<td>" + jackson.data.list[i].pos1 + "</td>" +
                        "<td>" + jackson.data.list[i].pos2 + "</td>" +
                        "<td>" + jackson.data.list[i].distance + "</td>" +
                        "<td>" + getStatusName(jackson.data.list[i].status) + "</td>" +
                        "<td>" + getLocalTime(jackson.data.list[i].createTime) + "</td>" +
                        "<td>" + jackson.data.list[i].userId + "</td>" +
                        "<td class=\"td-manage\">" +
                        /*"<a title=\"查看\"  onclick=\"x_admin_show('编辑','order-view.html')\" href=\"javascript:;\">" +
                        "<i class=\"layui-icon\">&#xe63c;</i>" +
                        " </a>" +*/
                        "<a title=\"删除\" onclick=\"orderDelete(this,'" + jackson.data.list[i].id + "')\" href=\"javascript:;\">" +
                        "<i class=\"layui-icon\">&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }

    })
};

function orderDelete(obj, id) {
    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/order/delete.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }
            }
        })

    });
};

//社区管理
function communityList(pageNum) {
    $("#communityList").html("");
    $.ajax({
        type: "post",
        url: host + "manage/community/list.do",
        data: {
            pageSize: 10,
            pageNum: pageNum
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            }
            else if (jackson.status == 0) {
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#communityList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td><img src='" + host + jackson.data.list[i].image + "'></td>" +
                        "<td>" + jackson.data.list[i].content + "</td>" +
                        "<td>" + getLocalTime(jackson.data.list[i].createTime) + "</td>" +
                        "<td>" + jackson.data.list[i].userId + "</td>" +
                        "<td class='td-manage'>\n" +
                        "<a title='删除' onclick=\"communityDelete(this,'" + jackson.data.list[i].id + "');\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )

                }

                let num = "";
                for (var i = 1; i < jackson.data.pages; i++) {
                    num += "<a class='num' href='javascript:0;' onclick='communityList(" + (jackson.data.pageNum + 1) + ")'>" + (jackson.data.pageNum + 1) + "</a>"
                }

                $("#communityPage").append(
                    "<div>" +
                    "<a class='prev' href=''>&lt;&lt;</a>" +
                    "<span class='current' >" + jackson.data.pageNum + "</span>" + num +
                    "<a class='next' href=''>&gt;&gt;</a>" +
                    "</div>")
            }
        }
    })
};

function communitySearch(content) {
    $.ajax({
        type: "post",
        url: host + "manage/community/search.do",
        data: {
            content: content
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                $("#communityList").html("");
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#communityList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td><img src='" + host + jackson.data.list[i].image + "'></td>" +
                        "<td>" + jackson.data.list[i].content + "</td>" +
                        "<td>" + getLocalTime(jackson.data.list[i].createTime) + "</td>" +
                        "<td>" + jackson.data.list[i].userId + "</td>" +
                        "<td class='td-manage'>\n" +
                        "<a title='删除' onclick=\"communityDelete(this,'" + jackson.data.list[i].id + "')\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }
    })
};

function communityDelete(obj, id) {
    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/community/delete.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }
            }
        })

    });
};

//评论管理
function commentsList() {
    $.ajax({
        type: "post",
        url: host + "manage/comments/list.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (var i = 0; i < jackson.data.list.length; i++) {
                    $("#commentsList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td>" + jackson.data.list[i].content + "</td>" +
                        "<td>" + jackson.data.list[i].star + "</td>" +
                        "<td>" + jackson.data.list[i].orderId + "</td>" +
                        "<td>" + jackson.data.list[i].userId + "</td>" +
                        "<td>" + formatDateTime(jackson.data.list[i].createTime) + "</td>" +
                        "<td class='td-status'>" +
                        "<a title='删除' onclick=\"commentsDelete(this," + jackson.data.list[i].id + ")\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }
    })
};

function commentsDelete(obj, id) {
    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/comments/delete.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg(jackson.data, {icon: 1, time: 1000});
                }
            }
        })
    })
};

//分类管理
function categoryList() {
    $.ajax({
        type: "post",
        url: host + "manage/other/categoryList.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (let i = 0; i < jackson.data.length; i++) {
                    $("#categoryList").append(
                        "<tr>" +
                        "<td>" +
                        "<div class= 'layui-unselect layui-form-checkbox' lay-skin='primary' data-id='2'>" +
                        "<i class='layui-icon'>&#xe605;</i>" +
                        "</div>" +
                        "</td>" +
                        "<td>" + jackson.data[i].id + "</td>" +
                        "<td>" + jackson.data[i].name + "</td>" +
                        "<td class='td-manage'>" +
                        "<a title='修改' onclick=\"x_admin_show('修改','category-update.html?id=" + jackson.data[i].id + "&nameOld=" + jackson.data[i].name + "',600,400)\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe642;</i>" +
                        "</a>" +
                        "<a title='删除' onclick=\"categoryDelete(this," + jackson.data[i].id + ")\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }
    })
};

function categoryDelete(obj, id) {

    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/other/deleteCategory.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }
            }
        })

    });
};

function categoryAdd() {
    $.ajax({
        type: "post",
        url: host + "manage/other/addCategory.do",
        data: {
            name: $("#L_name").val()
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
            }
        }
    })
};

function categoryUpdate(id, name) {
    $.ajax({
        type: "post",
        url: host + "manage/other/updateCategory.do",
        data: {
            id: id,
            name: name
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
            }
        }
    })
};

//积分管理
function integralList() {
    $.ajax({
        type: "post",
        url: host + "/manage/other/integralList.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (let i = 0; i < jackson.data.list.length; i++) {
                    $("#integralList").append(
                        "<tr>" +
                        "<td>" + jackson.data.list[i].id + "</td>" +
                        "<td>" + jackson.data.list[i].count + "</td>" +
                        "<td>" + jackson.data.list[i].rankId + "</td>" +
                        "<td>" + jackson.data.list[i].userId + "</td>" +
                        "<td class='td-manage'>" +
                        "<a title='修改' onclick=\"x_admin_show('修改积分','integral-update.html?userId=" + jackson.data.list[i].userId + "&countOld=" + jackson.data.list[i].count + "',600,400)\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe642;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }
    })
};

function integralUpdate(count, userId) {
    $.ajax({
        type: "post",
        url: host + "manage/other/updateIntegral.do",
        data: {
            count: count,
            userId: userId
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
            }
        }
    })
};

//等级管理
function rankList() {
    $.ajax({
        type: "post",
        url: host + "manage/other/rankList.do",
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                for (let i = 0; i < jackson.data.length; i++) {
                    $("#categoryList").append(
                        "<tr>" +
                        "<td>" +
                        "<div class= 'layui-unselect layui-form-checkbox' lay-skin='primary' data-id='2'>" +
                        "<i class='layui-icon'>&#xe605;</i>" +
                        "</div>" +
                        "</td>" +
                        "<td>" + jackson.data[i].id + "</td>" +
                        "<td>" + jackson.data[i].name + "</td>" +
                        "<td class='td-manage'>" +
                        "<a title='修改' onclick=\"x_admin_show('修改等级','rank-update.html?id=" + jackson.data[i].id + "&nameOld=" + jackson.data[i].name + "',600,400)\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe642;</i>" +
                        "</a>" +
                        "<a title='删除' onclick=\"rankDelete(this," + jackson.data[i].id + ")\" href='javascript:;'>" +
                        "<i class='layui-icon'>&#xe640;</i>" +
                        "</a>" +
                        "</td>" +
                        "</tr>"
                    )
                }
            }
        }
    })
};

function rankDelete(obj, id) {

    layer.confirm('确认要删除吗？', function (index) {
        //发异步删除数据
        $.ajax({
            type: "post",
            url: host + "manage/other/deleteRank.do",
            data: {
                id: id
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (jackson) {
                if (jackson.status == 1) {
                    if (jackson.msg == "你还未登陆,请先登录") {
                        layer.msg(jackson.msg, {icon: 1, time: 1000});
                        window.location.href = "login.html";
                    }
                } else if (jackson.status == 0) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }
            }
        })

    });

};

function rankUpdate(id, name) {
    $.ajax({
        type: "post",
        url: host + "manage/other/updateRank.do",
        data: {
            id: id,
            name: name
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
            }
        }
    })
};

function rankAdd() {
    $.ajax({
        type: "post",
        url: host + "manage/other/addRank.do",
        data: {
            name: $("#L_name").val()
        },
        xhrFields: {
            withCredentials: true
        },
        success: function (jackson) {
            if (jackson.status == 1) {
                if (jackson.msg == "你还未登陆,请先登录") {
                    layer.msg(jackson.msg, {icon: 1, time: 1000});
                    window.location.href = "login.html";
                }
            } else if (jackson.status == 0) {
                layer.msg(jackson.data, {icon: 1, time: 1000});
            }
        }
    })
};

UrlParm = function () { // url参数
    var data, index;
    (function init() {
        data = [];
        index = {};
        var u = window.location.search.substr(1);
        if (u != '') {
            var parms = decodeURIComponent(u).split('&');
            for (var i = 0, len = parms.length; i < len; i++) {
                if (parms[i] != '') {
                    var p = parms[i].split("=");
                    if (p.length === 1 || (p.length === 2 && p[1] === '')) {// p | p=
                        data.push(['']);
                        index[p[0]] = data.length - 1;
                    } else if (typeof(p[0]) === 'undefined' || p[0] === '') { // =c | =
                        data[0] = [p[1]];
                    } else if (typeof(index[p[0]]) === 'undefined') { // c=aaa
                        data.push([p[1]]);
                        index[p[0]] = data.length - 1;
                    } else {// c=aaa
                        data[index[p[0]]].push(p[1]);
                    }
                }
            }
        }
    })();
    return {
        // 获得参数,类似request.getParameter()
        parm: function (o) { // o: 参数名或者参数次序
            try {
                return (typeof(o) === 'number' ? data[o][0] : data[index[o]][0]);
            } catch (e) {
            }
        },
        //获得参数组, 类似request.getParameterValues()
        parmValues: function (o) { // o: 参数名或者参数次序
            try {
                return (typeof(o) === 'number' ? data[o] : data[index[o]]);
            } catch (e) {
            }
        },
        //是否含有parmName参数
        hasParm: function (parmName) {
            return typeof(parmName) === 'string' ? typeof(index[parmName]) != 'undefined' : false;
        },
        // 获得参数Map ,类似request.getParameterMap()
        parmMap: function () {
            var map = {};
            try {
                for (var p in index) {
                    map[p] = data[index[p]];
                }
            } catch (e) {
            }
            return map;
        }
    }
}();

function getStatusName(status) {
    if (status == 2) {
        return "已完成"
    } else if (status == 1) {
        return "未评论"
    } else if (status == 0) {
        return "未接订单"
    } else if (status == -1) {
        return "已取消"
    } else if (status == -2) {
        return "未付款"
    } else {
        return "正在进行"
    }
}

function formatDateTime(inputTime) {
    var date = new Date(inputTime);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
};

function getLocalTime(obj) {
    var date = new Date(obj);
    var y = 1900 + date.getYear();
    var m = "0" + (date.getMonth() + 1);
    var d = "0" + date.getDate();
    return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
}